<?php
#region CODE
use Gotcha\App\Framework\Controller;
use GotchaDatabase\GotchaSettingsQuery;

$framework = new Controller();
$gallery = new \Modules\JasminumGallery\Controllers\AdminController();

$settings = GotchaSettingsQuery::create()
                ->findOneByStrongName('GalleryThumbnailsDir');
$thumbnailsDir = $settings->getValue();
#endregion
?>
<div id="adminPanel">
    <header>
        <h1>Panel Administracyjny</h1>
    </header>
    <div id="adminContent" class="clearfix">
        <div id="adminNavigation" class="pull-left">
            <ul>
                <li>
                    <a href="<?= $framework->UrlContent("/Admin/StaticContent"); ?>">Treści statyczne</a>
                </li>
                <li>
                    <a href="<?= $framework->UrlContent("/Admin/Layout"); ?>">Układ stron</a>
                </li>
                <li>
                    <a href="<?= $framework->UrlContent("/Admin/Modules"); ?>">Moduły</a>
                </li>
                <li>
                    <a href="<?= $framework->UrlContent("/Admin/Settings"); ?>">Ustawienia</a>
                </li>
                <li>
                    <a href="<?= $framework->UrlContent("/Admin/Jasminum/Calendar"); ?>">Kalendarz</a>
                </li>
                <li>
                    <a href="<?= $framework->UrlContent("/Admin/Jasminum/Gallery"); ?>">Galeria</a>
                </li>
                <li>
                    <a href="<?= $framework->UrlContent("/Admin/Jasminum/Reservations"); ?>">Rezerwacje</a>
                </li>
                <li>
                    <a href="<?= $framework->UrlContent("/Admin/Jasminum/Menus"); ?>">Menu</a>
                </li>
                <li>
                    <a href="<?= $framework->UrlContent("/Admin/Jasminum/Newsletter"); ?>">Newsletter</a>
                </li>
                <li>
                    <a href="<?= $framework->UrlContent("/Admin/Jasminum/News"); ?>">Newsy</a>
                </li>
            </ul>
        </div>
        <div id="adminPage" class="pull-left" style="margin: 8px;">
            <header>
                <h2>Galeria - edytuj</h2>
            </header>
            <div id="adminStaticContent">
                <form method="post" action="<?= $framework->UrlContent("/Admin/Jasminum/Gallery/EditPost"); ?>" enctype="multipart/form-data">
                    <fieldset>
                        <label for="Name">Nazwa</label>
                        <input type="text" name="Name" id="Name" value="<?= $gallery->returnGallery($_GET['id'])->getName(); ?>">
                        <label for="Description">Opis</label>
                        <input type="text" name="Description" id="Description" value="<?= $gallery->returnGallery($_GET['id'])->getDescription(); ?>">
                        <p>Miniatura:</p>
                        <div style="margin: 10px 5px;">
                            <img src="<?= GOTCHA_BASE_PATH.$thumbnailsDir.$gallery->returnGallery($_GET['id'])->getImageSrc(); ?>" />
                        </div>
                        <label for="ImageSrc">Nowa miniatura</label>
                        <input type="file" name="ImageSrc" id="ImageSrc" value="">
                        <button type="submit">Zapisz</button>
                        <input type="hidden" name="Id" value="<?= $_GET['id']; ?>">
                        <input type="hidden" name="OldName" value="<?= $gallery->returnGallery($_GET['id'])->getName(); ?>">
                    </fieldset>
                </form>
            </div>
        </div>
    </div>
</div>